package com.huawei.hianalytics.f.f;

import android.content.Context;
import com.huawei.hianalytics.f.b.a;
import com.huawei.hianalytics.f.g.k;
import com.huawei.hianalytics.g.b;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.json.JSONArray;
import org.json.JSONObject;

public class j {
    protected Context a;
    String b;
    private String c;
    private String d;
    private String e;
    private String f;

    public j(String str, String str2, String str3, String str4, Context context) {
        this.a = context;
        this.c = str;
        this.d = str2;
        this.e = str3;
        this.f = str4;
    }

    public void a() {
        b.b("IMEventReportTask", "Stream Event run!");
        a aVar = new a(this.a);
        long currentTimeMillis = System.currentTimeMillis();
        aVar.f(this.f);
        aVar.e(this.d);
        aVar.d(this.e);
        aVar.c(currentTimeMillis + "");
        aVar.g(this.c);
        aVar.h(this.b);
        if ("oper".equals(this.d) && com.huawei.hianalytics.a.a.e(this.c, "oper")) {
            com.huawei.hianalytics.f.e.b a = com.huawei.hianalytics.f.e.a.a().a(this.c, currentTimeMillis);
            String a2 = a.a();
            Boolean valueOf = Boolean.valueOf(a.b());
            aVar.a(a2);
            aVar.b(valueOf + "");
        }
        String replace = UUID.randomUUID().toString().replace("-", "");
        if (com.huawei.hianalytics.f.g.b.a().b()) {
            JSONObject a3 = aVar.a();
            JSONArray jSONArray = new JSONArray();
            jSONArray.put(a3);
            com.huawei.hianalytics.f.g.b.a().a(jSONArray.toString(), com.huawei.hianalytics.f.g.j.a(this.c, this.d, replace));
        } else {
            b.b("IMEventReportTask", "backup file reach max limited size, discard new event ");
        }
        List arrayList = new ArrayList();
        arrayList.add(aVar);
        k.b(new a(this.a, arrayList, this.d, this.c, com.huawei.hianalytics.a.b.g(), replace));
    }
}
